<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:composite="http://java.sun.com/jsf/composite"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
	<h:body>
    	<ui:composition template="/resources/template/layout.xhtml">
    		<ui:define name="contentLayout">
    		

                <p:panel header="Registered VirtualServices" toggleable="true">
                    <p:spacer height="5"></p:spacer>
                   

                    <p:dataTable id="tableABM" var="config" value="#{serviceController.dataTable}" paginator="true"
                                 paginatorPosition="bottom" rows="15" emptyMessage="No record found" selectionMode="single"
                                 selection="#{serviceController.selectItem}" rowKey="#{config.serviceID}" >
                        
                        <p:ajax event="rowSelect" update="buttonSet" process="@this" listener="#{serviceController.newSelection}" />

                        <f:facet name="header">
                            VirtualService List
                        </f:facet>

                        <p:column headerText="serviceID">
                            <h:outputText value="#{config.serviceID}" />
                        </p:column>
                        <p:column headerText="endPointURL">
                            <h:outputText value="#{config.endPointURL}" />
                        </p:column>
                        <p:column headerText="virtualServiceName">
                            <h:outputText value="#{config.virtualServiceName}" />
                        </p:column>
                        <p:column headerText="virtualServiceCategory">
                            <h:outputText value="#{config.virtualServiceCategory}" />
                        </p:column>
                        <p:column headerText="esbProyectName">
                            <h:outputText value="#{config.esbProyectName}" />
                        </p:column>
                       

                        <f:facet name="footer">
                        	<h:panelGroup id="buttonSet" style="text-align:left;">
                            <p:commandButton title="New" icon="ui-icon-plus" actionListener="#{serviceController.create}" update=":form-footer:display" oncomplete="detail.show()" >
                                <f:setPropertyActionListener value="#{true}" target="#{serviceController.editMode}" />
                                <f:setPropertyActionListener value="#{true}" target="#{serviceController.newMode}" />
                            </p:commandButton>
                            <p:commandButton title="Edit" widgetVar="btnEdit" icon="ui-icon-pencil" update=":form-footer:display" oncomplete="detail.show()" disabled="#{empty serviceController.selectItem}" >
                                <f:setPropertyActionListener value="#{true}" target="#{serviceController.editMode}" />
                                <f:setPropertyActionListener value="#{false}" target="#{serviceController.newMode}" />
                            </p:commandButton>
                            <p:commandButton title="Remove" widgetVar="btnDelete" icon="ui-icon-close" oncomplete="confirmation.show()" disabled="#{empty serviceController.selectItem}"/>
                       
                            <p:commandButton title="Update" icon="ui-icon-refresh" actionListener="#{serviceController.reload}" update=":form-layout:tableABM"  />
                             <h:panelGroup style="margin-right: 2.5px;">|</h:panelGroup>
                            <p:commandButton title="Metadata" icon="ui-icon-document" action="../services/servicemetaadm.xhtml"  ajax="false" disabled="#{empty serviceController.selectItem}" >
                             	<f:param name="id" value="#{serviceController.selectItem.serviceID}" /> 
                            </p:commandButton>        
                            <p:commandButton title="Equivalents" icon="ui-icon-transferthick-e-w" action="../services/serviceequiv.xhtml"  ajax="false" disabled="#{empty serviceController.selectItem}">
                             	<f:param name="id" value="#{serviceController.selectItem.serviceID}" /> 
                            </p:commandButton> 

							<p:commandButton title="Upload XSL" widgetVar="upload" icon="ui-icon-folder-open"  oncomplete="uploadDialog.show()" disabled="#{empty serviceController.selectItem}" />
                              
                        </h:panelGroup>
                        </f:facet>
                    </p:dataTable>

                    <p:spacer height="20"></p:spacer>
                </p:panel>
           
       			</ui:define>
       			
       			<ui:define name="contentFotter">       		
        	
                <p:dialog id="display" header="VirtualServices" widgetVar="detail" resizable="false" width="450"  modal="true" >
                    <h:panelGrid columns="2" cellpadding="4" rendered="#{serviceController.selectItem != null}">
                      
                        
                        <h:outputText value="Service ID :" styleClass="bold" rendered="#{!serviceController.newMode}" />
                        <p:inputText value="#{serviceController.selectItem.serviceID}" rendered="#{!serviceController.newMode}"  disable ="true"  size="25" />
                        
                        <h:outputText value="Service Name :" styleClass="bold" />
                        <p:inputText value="#{serviceController.selectItem.virtualServiceName}" required="true"  requiredMessage="The service name is required" size="25" />
                        
                        <h:outputText value="Service Category :" styleClass="bold" />
                        <p:inputText value="#{serviceController.selectItem.virtualServiceCategory}" required="true"  requiredMessage="The service category name is required" size="25" />
                        
                        <h:outputText value="EndPoint URL:" styleClass="bold" />
                        <p:inputText value="#{serviceController.selectItem.endPointURL}" required="true"  requiredMessage="The service endpoint url is required" size="40" />
                        
                        <h:outputText value="ESB Proyect:" styleClass="bold" />
                        <p:inputText value="#{serviceController.selectItem.esbProyectName}" required="true"  requiredMessage="The proyect name is required" size="25" />
                        
                        
                        <h:outputText value="XSL To canonical" styleClass="bold" rendered="#{!serviceController.newMode}"/>
                        <p:commandButton id="ToCan" value="View" type="button" rendered="#{!serviceController.newMode}"/> 
                        
                        <h:outputText value="XSL From canonical" styleClass="bold" rendered="#{!serviceController.newMode}"/>
                        <p:commandButton id="FromCan" value="View" type="button" rendered="#{!serviceController.newMode}"  /> 
                                               
                        
                        <p:spacer height="0"></p:spacer>
                        <p:spacer height="0"></p:spacer>

                        <f:facet name="footer">
                            <p:outputPanel rendered="#{serviceController.editMode}" layout="block" style="text-align:right">
                                <p:commandButton value="save" icon="ui-icon-check" actionListener="#{serviceController.save}" oncomplete="detail.hide();" update=":form-layout:tableABM" />
                                <p:commandButton value="cancel" onclick="detail.hide()" type="button" icon="ui-icon-close"/>
                            </p:outputPanel>
                        </f:facet>
                        
                        <br></br>                       
					         
                    </h:panelGrid>
                </p:dialog>

                <p:confirmDialog message="Are you sure to delete this record?" width="300" header="Please confirm the action" severity="alert" widgetVar="confirmation" >
                    <p:commandButton value="Yes" actionListener="#{serviceController.delete}" oncomplete="confirmation.hide()" update=":form-layout:tableABM" />
                    <p:commandButton value="No" onclick="confirmation.hide()" type="button" />
                </p:confirmDialog>
                
                
                <p:overlayPanel id="ToCanOverlay" for="ToCan" hideEffect="fade" dynamic="true" my="display" >  
			  			  <p:outputPanel id="toCanScrollPanel" autoUpdate="true">  
				  			  <p:scrollPanel  style="width:700px;height:300px">  			  			 
				  			  	<pre>#{serviceController.toCan}</pre>			
				  			  </p:scrollPanel>
				  		  </p:outputPanel>	 	  
			    </p:overlayPanel> 
			    
			     <p:overlayPanel id="FromCanOverlay" for="FromCan" hideEffect="fade" dynamic="true" my="display">
			     	<p:outputPanel id="fromCanScrollPanel"  autoUpdate="true">  
			  			  <p:scrollPanel  style="width:700px;height:300px" >  
			  			  	<pre>#{serviceController.fromCan}</pre>	
			  			  </p:scrollPanel>
			  		</p:outputPanel>	  
			    </p:overlayPanel> 
           
    		</ui:define>
    		
    		<ui:define name="otherContentFotter">       
    		
    			<p:dialog id="upload" header="VirtualServices" widgetVar="uploadDialog" resizable="false" width="550"  modal="true" >
    				<h:form id="upload1" prependId="false" enctype="multipart/form-data">
    					<p:fileUpload fileUploadListener="#{serviceController.handleXSLTToCanonical}"  
					                      mode="advanced"   
					                      label="To canonical Transformation"
					                      auto="false"
					                      sizeLimit="20000000"   					                    
					                      allowTypes="/(\.|\/)(xsl)$/"/>    				
    				</h:form>
    				
    				<h:form id="upload2" prependId="false" enctype="multipart/form-data">
    					<p:fileUpload fileUploadListener="#{serviceController.handleXSLTFromCanonical}"  
					                      mode="advanced"   
					                      label="From canonical Transformation"
					                      auto="false"
					                      sizeLimit="20000000"   					                    
					                      allowTypes="/(\.|\/)(xsl)$/"/>    				
    				</h:form>
    				
    				  </p:dialog>
    		</ui:define>
    		
    	</ui:composition>
    </h:body>
</html>